﻿using System.Windows;
using Blurift.WPFGLControl;
using Crevice2D.WPFEditorHost;
using Crevice2D.WPFEditorHost.Infrastructure;
using Patyk.MapEdit;
using Patyk.MapEditor.Modals;
using Patyk.MapEditor.Models;

namespace Patyk.MapEditor
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : BaseWindow
    {
        public MainWindow()
        {
            InitializeComponent();

            _editor = new Level();

            renderWindow.Child = RenderManager.GLDevice;
        }

        protected override void HwndMouseMove(object sender, HwndMouseEventArgs e)
        {
            workSpaceWidth.Text = string.Format("Width: {0}", ((int)e.Position.X).ToString());
            workSpaceHeight.Text = string.Format("Height: {0}", ((int)e.Position.Y).ToString());
            
            base.HwndMouseMove(sender, e);
        }

        #region WPF Window Event Handlers

        private void newMapMnu_Click(object sender, RoutedEventArgs e)
        {
            var newMapModal = new NewMapModal();
            var mapData = newMapModal.ShowNewMapDialog();
            if (mapData != null)
            {
                var map = new Map(mapData.Name, mapData.Width, mapData.Height, (float)Width, (float)Height);
                _editor = new Level(map);
            }
        }

        private void exitMnu_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        #endregion
    }
}
